{extend name="layout"/}
{block name="content"}
<div class="panel">
    <div class="panel-heading">
        <span class="panel-title">用户分组列表</span>
        <div class="panel-heading-controls"> 
            <a class="btn btn-xs btn-primary" href="{:url('add')}"><i class="fa fa-plus"></i> 新增分组</a>
        </div>
    </div>
    <div class="panel-body">
            <div class="table-responsive">
                <table class="table table-bordered table-hover">
                    <tr>
                        <th>分组英文标识</th><th>分组名称</th><th width="160">创建时间</th><th width="100">操作</th>
                    </tr>

                    {volist name="llist" id="vo"}
                    <tr id="{$vo.id}">
                        <td>{$vo.name}</td>
                        <td>{$vo.title}</td>
                        <td>{$vo.create_time}</td>
                        <td><a href="{:url('edit',['id'=>$vo.id])}"><i  class="fa fa-edit btn  btn-sm btn-primary" data-toggle="tooltip" data-placement="top"  data-original-title="编辑"></i></a> <i  class="fa fa-times btn  btn-sm btn-warning del" data-toggle="tooltip" data-placement="top"  data-original-title="删除"></i></td>
                    </tr>
                    {/volist}
                    
                    {notempty name="page"}
                    <tr>
                        <td colspan="4">
                             {$page|raw}
                        </td>
                    </tr>
                    {/notempty}
                </table>
            </div>
    </div>
</div>
{/block}

{block name="javascript"}
<script>
    $(function () {
        $('[data-toggle="tooltip"]').tooltip();
        $('.del').click(function () {
            var nowdom = $(this).parent().parent();
            bootbox.confirm({
                message: '确认删除吗？删除后不可恢复',
                className: 'bootbox-sm',
                callback: function (result) {
                    if (result) {
                        var id = nowdom.attr('id');
                        $.ajax({
                            url: "{:url('delete')}",
                            type: "GET",
                            data: {
                                id: id
                            },
                            dataType: 'text',
                            success: function (data) {
                                if (data === 'true') {
                                    nowdom.remove();
                                    toastr['success']('广告分组删除成功~', '', {
                                        closeButton: true
                                    });
                                } else {
                                    toastr['warning'](data, '', {
                                        closeButton: true
                                    });
                                }
                            }
                        });
                    }
                }
            });
        });
    });
</script>
{/block}